package com.supermap.logger;

import org.apache.commons.lang3.StringUtils;
import org.apache.log4j.FileAppender;
import org.apache.log4j.LogManager;
import org.apache.log4j.PatternLayout;

public class LoggerUtil {

    public static void initLogger(String logPath) {
        if(StringUtils.isNotBlank(logPath)) {
            FileAppender file = new FileAppender();
            file.setName("fileout");
            file.setEncoding("utf-8");
            PatternLayout layout = new PatternLayout();
            layout.setConversionPattern("[%p] %d{yyyy-MM-dd HH:mm:ss} %m%n");
            file.setLayout(layout);
            file.setFile(logPath + "/log.txt");
            file.activateOptions();
            LogManager.getRootLogger().addAppender(file);
        }
    }
    
}
